﻿    //- - - - - - - - - - - - -//
   //  PPMS冒险岛赞助礼包点卷 //
  //      Date：2018.6.23    //
 //       by:PPMS修改       //
//- - - - - - - - - - - - -//

var usd = "#fEffect/CharacterEff/1082565/0/0#"; //饼干兔子
var xf = "#fUI/UIWindow2/ValuePack/title/0#"; //充值横幅
var tt1 = "#fUI/UIWindow2/FadeYesNo/icon5#"; //支付
var tt = "#fUI/UIWindow2/FadeYesNo/icon3#"; //蘑菇
// 每个阶段礼包所需的充值数
var condition = [100000, 200000, 300000, 400000, 500000, 600000, 700000, 800000, 900000, 1000000];//总共分了10个阶段
// 礼包内容
var reward = [Array(1, 2436626, 1), //鲁塔比斯FFN防具箱x1
        Array(1, 2433853, 1), //随机稀有椅子无垃圾版x1
        Array(1, 3064310, 2), //[S] 星岩 (全属性+5%)x2
        Array(1, 2049337, 2), //3星强化卷轴100%x1
        Array(1, 2049124, 5), //正向混沌卷轴50%x5
        Array(1, 2340000, 5), //祝福卷轴	   x5
        Array(1, 2614029, 5), //突破一万之石50%x5				
        Array(1, 4001839, 88), //星星         x88		
        Array(1, 4005000, 12),  //力量水晶x12
        Array(1, 4005002, 12), //敏捷水晶x12
        Array(1, 4005003, 12), //幸运水晶x12
        Array(1, 4005001, 12), //智慧水晶x12
        Array(1, 4021007, 12), //钻石x12
        Array(1, 4021000, 12), //石榴石x12
        Array(1, 4021002, 12), //海蓝宝石x12	
        Array(1, 4021004, 12), //蛋白石x12

        // 礼包2 200元
        Array(2, 2436626, 2), //鲁塔比斯FFN防具箱x2
		Array(2, 2433853, 2), //随机稀有椅子无垃圾版x2
        Array(2, 3064310, 2), //[S] 星岩 (全属性+5%)x2
        Array(2, 2049337, 3), //3星强化卷轴100%x3
        Array(2, 2049124, 8), //正向混沌卷轴50%x8
        Array(2, 2340000, 8), //祝福卷轴	   x8
        Array(2, 2614032, 5), //突破5万之石30%x5				
        Array(2, 4001839, 188), //星星         x188		
        Array(2, 4005000, 15),  //力量水晶x15
        Array(2, 4005002, 15), //敏捷水晶x15
        Array(2, 4005003, 15), //幸运水晶x15
        Array(2, 4005001, 15), //智慧水晶x15
        Array(2, 4021007, 15), //钻石x15
        Array(2, 4021000, 15), //石榴石x15
        Array(2, 4021002, 15), //海蓝宝石x15	
        Array(2, 4021004, 15), //蛋白石x15
		
	    // 礼包3 300元
        Array(3, 2431938, 1),//鲁塔比斯FFN武器箱x1 		
        Array(3, 2436626, 3),//鲁塔比斯FFN防具箱x3 	
		Array(3, 2433853, 3), //随机稀有椅子无垃圾版x3 		
        Array(3, 3064311, 2),//[S] 星岩 (全属性+6%)x2 			
        Array(3, 2049338, 3),//4星强化卷轴 		
        Array(3, 2049124, 10), //正向混沌卷轴50%x11
        Array(3, 2340000, 10), //祝福卷轴	   x11
        Array(3, 2614042, 8), //突破石 5万 50% x8					
        Array(3, 4001839, 288), //星星         x288		
        Array(3, 4005000, 18),  //力量水晶x18
        Array(3, 4005002, 18), //敏捷水晶x18
        Array(3, 4005003, 18), //幸运水晶x18
        Array(3, 4005001, 18), //智慧水晶x18
        Array(3, 4021007, 18), //钻石x18
        Array(3, 4021000, 18), //石榴石x18
        Array(3, 4021002, 18), //海蓝宝石x18	
        Array(3, 4021004, 18), //蛋白石x18
		
	    // 礼包4 400元
        Array(4, 2431938, 2), //鲁塔比斯FFN武器箱x2 			
        Array(4, 2436626, 3), //鲁塔比斯FFN防具箱x3 
		Array(4, 2433853, 4), //随机稀有椅子无垃圾版x4
		Array(4, 3063270, 2),//[A] 星岩 (所有伤害 5%)	x 2		
        Array(4, 2049705, 5),//A级潜能附加卷轴 50%	 x5
        Array(4, 2049453, 5),//特殊潜能附加卷轴100%	 x5		
        Array(4, 2049339, 4),//5星强化卷轴 	x4	
        Array(4, 2431338, 3), //祥龙卷轴箱x3
        Array(4, 2614045, 8), //突破石 10万 50% x8					
        Array(4, 4001839, 388), //星星         x288		
        Array(4, 4250800, 18),  //下等力量水晶x18
        Array(4, 4251100, 18), //下等敏捷水晶x18
        Array(4, 4251000, 18), //下等幸运水晶x18
        Array(4, 4250900, 18), //下等智慧水晶x18
        Array(4, 4250000, 18), //下等钻石x18
        Array(4, 4250200, 18), //下等石榴石x18
        Array(4, 4250500, 18), //下等海蓝宝石x18	
        Array(4, 4250300, 18), //下等蛋白石x18
		
	    // 礼包5 500元	
        Array(5, 2434340, 2), //埃苏莱布斯防具箱x2		
		Array(5, 2433853, 5), //随机稀有椅子无垃圾版x5
		Array(5, 3063271, 2),//[A] 星岩 (所有伤害 6%)	x 2		
        Array(5, 2049705, 8),//A级潜能附加卷轴 50%	 x8
        Array(5, 2049453, 8),//特殊潜能附加卷轴100%	 x8		
        Array(5, 2049340, 4),//6星强化卷轴 	x4	
        Array(5, 2431338, 6), //祥龙卷轴箱x6
        Array(5, 2614036, 8), //突破石 20万 50% x8					
        Array(5, 4001839, 488), //星星         x488		
        Array(5, 4250800, 21),  //下等力量水晶x21
        Array(5, 4251100, 21), //下等敏捷水晶x21
        Array(5, 4251000, 21), //下等幸运水晶x21
        Array(5, 4250900, 21), //下等智慧水晶x21
        Array(5, 4250000, 21), //下等钻石x21
        Array(5, 4250200, 21), //下等石榴石x21
        Array(5, 4250500, 21), //下等海蓝宝石x21	
        Array(5, 4250300, 21), //下等蛋白石x21
		
	    // 礼包6 600元
        Array(6, 2435690, 1),//埃苏莱布斯武器箱x1					
        Array(6, 2434340, 4),//埃苏莱布斯防具箱x4
		Array(6, 2433853, 6), //随机稀有椅子无垃圾版x6
        Array(6, 3064290, 2),//[S] 星岩 (所有伤害 7%)	x 2			
        Array(6, 2049705, 10),//A级潜能附加卷轴 50%	 x10
        Array(6, 2049453, 10),//特殊潜能附加卷轴100%	 x10		
        Array(6, 2049340, 4),//6星强化卷轴 	x4	
        Array(6, 2431355, 6), //星火卷轴箱x6
        Array(6, 2614036, 8), //突破石 20万 50% x8					
        Array(6, 4001839, 588), //星星         x588		
        Array(6, 4250800, 21),  //下等力量水晶x21
        Array(6, 4251100, 21), //下等敏捷水晶x21
        Array(6, 4251000, 21), //下等幸运水晶x21
        Array(6, 4250900, 21), //下等智慧水晶x21
        Array(6, 4250000, 21), //下等钻石x21
        Array(6, 4250200, 21), //下等石榴石x21
        Array(6, 4250500, 21), //下等海蓝宝石x21	
        Array(6, 4250300, 21), //下等蛋白石x21
		
        // 礼包7 700元
        Array(7, 2435690, 2),//埃苏莱布斯武器箱x2 	
        Array(7, 2434340, 6),//埃苏莱布斯防具箱x6 	
		Array(7, 2433853, 7), //随机稀有椅子无垃圾版x7		
        Array(7, 3064290, 2),//[S] 星岩 (所有伤害 7%)	x 2		
        Array(7, 2049765, 6),//S级潜能附加卷轴 60%	 x6
        Array(7, 2049765, 6),//S级潜能卷轴 60%	 x6		
        Array(7, 2049342, 4),//8星强化卷轴 	x4	
        Array(7, 2435572, 6), //X卷轴箱x6
        Array(7, 2614037, 10), //突破石 20万 100% x10					
        Array(7, 4001839, 688), //星星         x688		
        Array(7, 4250801, 21),  //中等力量水晶x21
        Array(7, 4251101, 21), //中等敏捷水晶x21
        Array(7, 4251001, 21), //中等幸运水晶x21
        Array(7, 4250901, 21), //中等智慧水晶x21
        Array(7, 4250001, 21), //中等钻石x21
        Array(7, 4250201, 21), //中等石榴石x21
        Array(7, 4250501, 21), //中等海蓝宝石x21	
        Array(7, 4250301, 21), //中等蛋白石x21
		
		// 礼包8 800元
        Array(8, 2436245, 2), //神秘之影防具箱		
		Array(8, 2433853, 8), //随机稀有椅子无垃圾版x8
		Array(8, 3063350, 2),//[A] 星岩 (Boss伤害 20%)	x 2	
        Array(8, 2049765, 8),//S级潜能附加卷轴 60%	 x8
        Array(8, 2049765, 8),//S级潜能卷轴 60%	 x8		
        Array(8, 2049343, 4),//9星强化卷轴 	x4	
        Array(8, 2435572, 8), //X卷轴箱x8
        Array(8, 2614037, 10), //突破石 20万 100% x10					
        Array(8, 4001839, 788), //星星         x788		
        Array(8, 4250801, 24),  //中等力量水晶x24
        Array(8, 4251101, 24), //中等敏捷水晶x24
        Array(8, 4251001, 24), //中等幸运水晶x24
        Array(8, 4250901, 24), //中等智慧水晶x24
        Array(8, 4250001, 24), //中等钻石x24
        Array(8, 4250201, 24), //中等石榴石x24
        Array(8, 4250501, 24), //中等海蓝宝石x24	
        Array(8, 4250301, 24), //中等蛋白石x24
		
	    // 礼包9 900元
        Array(9, 2436244, 1), //神秘之影武器箱		
        Array(9, 2436245, 4), //神秘之影防具箱	
		Array(9, 2433853, 9), //随机稀有椅子无垃圾版x9		
		Array(9, 3063351, 2),//[A] 星岩 (Boss伤害 25%)	x 2			
        Array(9, 2049757, 10),//S级潜能附加卷轴 	 x10
        Array(9, 2049762, 10),//S级潜能卷轴 100%	 x10		
        Array(9, 2049344, 4),//10星强化卷轴 	x4	
        Array(9, 2435824, 8), //V卷轴箱x8
        Array(9, 2614049, 6), //突破石 50万 100% x6					
        Array(9, 4001839, 888), //星星         x888		
        Array(9, 4250801, 27),  //中等力量水晶x27
        Array(9, 4251101, 27), //中等敏捷水晶x27
        Array(9, 4251001, 27), //中等幸运水晶x27
        Array(9, 4250901, 27), //中等智慧水晶x27
        Array(9, 4250001, 27), //中等钻石x27
        Array(9, 4250201, 27), //中等石榴石x27
        Array(9, 4250501, 27), //中等海蓝宝石x27	
        Array(9, 4250301, 27), //中等蛋白石x27
		
	    // 礼包10 1000元
        Array(10, 2436244, 2),//神秘之影武器箱		
        Array(10, 2436245, 6),//神秘之影防具箱
		Array(10, 2433853, 10), //随机稀有椅子无垃圾版x10
        Array(10, 3064430, 2),//[S] 星岩 (所有伤害 30%)	x 2		
        Array(10, 2049757, 12),//S级潜能附加卷轴 	 x12
        Array(10, 2049762, 12),//S级潜能卷轴 100%	 x12		
        Array(10, 2049344, 4),//10星强化卷轴 	x4	
        Array(10, 2435824, 10), //V卷轴箱x10
        Array(10, 2614049, 8), //突破石 50万 100% x8					
        Array(10, 4001839, 1088), //星星         x1088		
        Array(10, 4250802, 30),  //高等力量水晶x30
        Array(10, 4251102, 30), //高等敏捷水晶x30
        Array(10, 4251002, 30), //高等幸运水晶x30
        Array(10, 4250902, 30), //高等智慧水晶x30
        Array(10, 4250002, 30), //高等钻石x30
        Array(10, 4250202, 30), //高等石榴石x30
        Array(10, 4250502, 30), //高等海蓝宝石x30	
        Array(10, 4250302, 30)]; //高等蛋白石x30
				
		


var sel;
var status = -1;
var text;
var ljname;
var curlevel = -1;
function start() {
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else {
        status--;
    }

    if (status == 0) {
        var revenue = cm.getTotalCostACash();
        text = "\r\n"+"" + " #e#r PPMS点券赞助答谢大礼包#k#n " + "\r\n";
        text += " #n#d 注意:您必须先消耗点点券才能领取下面的对应礼包！#k#n " + "\r\n";		
        text += " #n#d 各种累计消耗赞助的礼包内容是不一样的请看清楚再选择！" + "\r\n";				
        text += "#k#n  您当前消费点券总量 #r" + revenue.formatMoney(0, "") + " #d点券#k\r\n#e#d"; //cm.getTotalCostACash() 判断累计点卷的
        for (var i = 1; i <= condition.length; i++) {
            if (cm.getEventCount("累计赞助礼包" + i, 1) == 1) {
                text += "#b#L" + i + "#" + tt + " #g[已领取]#d赞助点券达到#r " + condition[i - 1] + " 即可领取#l\r\n";
                curlevel = curlevel == -1 ? i : curlevel;
            } else {
                text += "#b#L" + i + "#" + tt + " #r[未领取]#k赞助点券达到#r " + condition[i - 1] + " 即可领取#l\r\n";
            }
        }
        text += "#k";
        cm.sendSimple(text);
    } else if (status == 1) {
        sel = selection;
        text = "\t\t\t#e#r- 累计赞助" + condition[selection - 1] + "点券福利 -#k#n\r\n\r\n";
        for (var i = 0; i < reward.length; i++) {
            if (reward[i][0] == selection) {
                text += "\t\t\t#i" + reward[i][1] + "# #z" + reward[i][1] + "#[" + reward[i][2] + "个]\r\n";
            }
        }
        cm.sendYesNo(text);
    } else if (status == 2) {
        if (cm.getEventCount("累计赞助礼包" + sel, 1) == 1) {
            cm.sendOk("#e#r\r\n\r\n\t\t这个礼包您已经领取过了");
            status = -1;
            //cm.dispose();
            return;
        }
        if (cm.getTotalCostACash() < condition[sel - 1]) {
            cm.playerMessage(1, "领取失败:                      \r\n\r\nSorry！您的累计赞助点券未达标！\r\n\r\n比如您想领取100000点券的答谢礼包\r\n\r\n需要让您的账户点券消耗量达到10万\r\n\r\n否则无法领取这个答谢礼包哦！\r\n\r\n如有疑问可联系管理员QQ:2756747596\r\n\r\n                 by:PPMSの管理员");
            cm.dispose();
            return;
        }

        var rewardlist = [];
        for (var i = 0; i < reward.length; i++) {
            if (reward[i][0] == sel) {
                if (reward[i][3] == null)
                    reward[i][3] = -1;
                rewardlist.push([reward[i][1], reward[i][2], reward[i][3]]);
            }
        }
        if (!cm.canHoldSlots(rewardlist.length)) {
            cm.sendOk("包裹空间不足，请确保包裹每个栏位有至少 " + rewardlist.length + " 格空间");
            cm.dispose();
            return;
        }
        for (var i = 0; i < rewardlist.length; i++) {
            if (rewardlist[i][0] == 2430865) {
                cm.gainItem(rewardlist[i][0], rewardlist[i][1], rewardlist[i][2]);
            } else {
                cm.gainItem(rewardlist[i][0], rewardlist[i][1]);
            }
        }
        cm.setEventCount("累计赞助礼包" + sel, 1);
        cm.playerMessage(1, "赞助累计点券礼包已送达！\r\n\r\n您有新的包裹到达！请注意查收！\r\n\r\n礼包道具已存入您的背包！");
        cm.worldSpouseMessage(0x20, "≡累计赞助≡　　恭喜玩家 " + cm.getChar().getName() + " 领取了累计赞助 " + condition[sel - 1] + " 点券的福利礼包！！！");
        cm.dispose();
    }
}

Number.prototype.formatMoney = function (places, symbol, thousand, decimal) {
    places = !isNaN(places = Math.abs(places)) ? places : 2;
    symbol = symbol !== undefined ? symbol : "　";
    thousand = thousand || ",";
    decimal = decimal || ".";
    var number = this,
            negative = number < 0 ? "-" : "",
            i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
            j = (j = i.length) > 3 ? j % 3 : 0;
    return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
};